wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
{{"value":"hello",}} | {{"value":"hello"}} | Remove trailing comma. | JSON |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
for (data in arr) | for (data of arr) | for...in iterates keys. | JavaScript |
if [ $z = 86 ]; then | if [ "$z" = 86 ]; then | Quote variable. | Shell |
items(77) | if length(items) >= 77, items(77), end | Check length. | MATLAB |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
while foo > 78
foo -= 1 | while foo > 78:
foo -= 1 | Colon missing after while. | Python |
<br></br> | <br> | Self-closing. | HTML |
let list=vec![8,37,17]; let head=&list[0]; list.push(36); | let mut list=vec![8,37,17]; let head=list[0]; list.push(36); | Copy instead of reference. | Rust |
WHERE age = '14' | WHERE age = 14 | Don't quote integer. | SQL |
class User {{ int z; }}; | class User {{ public: int z; }}; | Make public. | C++ |
let item: number = 'message'; | let item: string = 'message'; | Fix type. | TypeScript |
fn baz() -> i32 {{ 71 }} | fn baz() -> i32 {{ 71 }} | Correct. | Rust |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
<entry name='hello'/> | <entry name="hello"/> | Double quotes. | XML |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
val y = 18; y = 28 | var y = 18; y = 28 | Use var for reassignment. | Scala |
jwt.sign({{id:59}}, 'password'); | jwt.sign({{id:59}}, 'password', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
var x = 37; | var x = 37; | Correct. | Dart |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
b == '89' | b === 89 | Use strict equality. | JavaScript |
if count = 54 | if count == 54 | Use ==. | Go |
<person age=59> | <person age="59"> | Quote attribute. | XML |
if (bar = 91) {{}} | if (bar == 91) {{}} | Use ==. | Kotlin |
if ($data = 41) {{}} | if ($data -eq 41) {{}} | Use -eq. | PowerShell |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
print 'info' | print('info') | print needs parentheses. | Python |
if z = 58 then
print('result')
end | if z == 58 then
print('result')
end | Use ==. | Lua |
val val: Int = 'info' | val val: String = 'info' | Fix type. | Kotlin |
z = world | z = 'world' | Quote strings. | Python |
if (temp = 2) {{}} | if (temp === 2) {{}} | Use === for equality. | JavaScript |
if (z = 80) | if (z == 80) | Use ==. | C++ |
DELETE FROM orders WHERE id=74 | DELETE FROM orders WHERE id=74; | Add semicolon. | SQL |
def process(temp):
return temp + 1 | def process(temp):
return temp + 1 | Correct. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<hr></hr> | <hr> | Self-closing. | HTML |
[65, 25, 18 | [65, 25, 18] | Close bracket. | Ruby |
let index = 'result' | let index = "result" | Double quotes. | Swift |
println('result') | println("result") | Double quotes. | Scala |
items[47] | if items.indices.contains(47) {{ items[47] }} | Check index. | Swift |
name: output
age: 54 | name: output
age: 54 | Correct. | YAML |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
print 'world' | print 'world'; | Add semicolon. | Perl |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
const p:Person = {{name:'data'}}; | const p:Person = {{name:'data', age:7}}; | Add missing property. | TypeScript |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
int[] data = new int[95];
data[95] = 5; | int[] data = new int[95];
if (95 < data.length) data[95] = 5; | Check bounds. | Java |
UPDATE items SET name='result' WHERE status=2 | UPDATE items SET name='result' WHERE status=2; | Add semicolon. | SQL |
[x*x for x in list if x > 50] | [x*x for x in list if x > 50] | Correct list comprehension. | Python |
x := 28 | x := 28 | Correct. | Go |
$num = 37; if ($num = 37) {{}} | $num = 37; if ($num == 37) {{}} | Use ==. | PHP |
value: message
name: world, | value: message
name: world | Remove comma. | YAML |
y > 70 & a < 50 | y > 70 and a < 50 | Use 'and' not '&'. | Python |
const index = 41; index = 72; | let index = 41; index = 72; | Cannot reassign const. | JavaScript |
function bar(): void {{ return 46; }} | function bar(): number {{ return 46; }} | Return type mismatch. | TypeScript |
if b > 50
puts 'output' | if b > 50
puts 'output'
end | Add 'end'. | Ruby |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(5); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(5, () => console.log('listening')); | Add callback. | Node.js |
{{'id':48, 'value' 72}} | {{'id':48, 'value':72}} | Colon missing. | Python |
["message", 82] | ["message", 82] | Correct. | JSON |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
val foo = 'world' | val foo = "world" | Double quotes. | Kotlin |
h1 {{ font-size:72px color:#fff; }} | h1 {{ font-size:72px; color:#fff; }} | Add semicolon. | CSS |
for i=1,94 do print(i) end | for i=1,94 do print(i) end | Correct. | Lua |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
if (a) console.log('yes') else console.log('no') | if (a) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
data.forEach(function(temp) {{ console.log(temp); }}) | data.forEach((temp) => {{ console.log(temp); }}) | Arrow functions are cleaner. | JavaScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
int data[15]; data[15]=5; | int data[15]; if(15<15){{}} else data[15]=5; | Bounds check. | C++ |
def process():
print('result') | def process():
print('result') | Indent function body. | Python |
if temp > 14
print('message') | if temp > 14:
print('message') | Colon missing after if. | Python |
if z = 59 {{}} | if z == 59 {{}} | Use ==. | Swift |
echo value hello | echo 'value hello' | Quote to prevent splitting. | Shell |
with open('config.json') as file_handle:
data = file_handle.read() | with open('config.json') as file_handle:
data = file_handle.read() | Correct. | Python |
.Order {{ color: blue; }} | .Order {{ color: blue; }} | Correct. | CSS |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
if (data = 44) {} | if (data == 44) {} | Use ==. | Dart |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if ($foo = 17) | if ($foo == 17) | Use ==. | Perl |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
else
print('value') | else:
print('value') | Colon after else. | Python |
const a; | const a = 32; | Initialize const. | JavaScript |
<table><tr><td>world<td>test</tr></table> | <table><tr><td>world</td><td>test</td></tr></table> | Close td. | HTML |
int z = 'test'; | String z = 'test'; | Type mismatch. | Dart |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
class Product {{ int bar; }}
obj.bar=5; | class Product {{ public int bar; }}
obj.bar=5; | Make field public. | Java |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
if (item = 54) {{}} | if (item == 54) {{}} | Use ==. | Java |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
<person><age>test</age><age>90</age></person | <person><age>test</age><age>90</age></person> | Add closing >. | XML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.