wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
for y in range(28)
print(y) | for y in range(28):
print(y) | Colon after for. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
jwt.sign({{id:12}}, 'password'); | jwt.sign({{id:12}}, 'password', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
SELECT * FROM products WHRE age=95; | SELECT * FROM products WHERE age=95; | Fix WHERE. | SQL |
[x*x for x in data if x > 96] | [x*x for x in data if x > 96] | Correct list comprehension. | Python |
for (int i=0; i<57; i++) {{}} | for (int i=0; i<57; i++) {{}} | Correct. | Java |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
a = info | a = 'info' | Quote strings. | Python |
assert b > 15 | assert b > 15 | Correct. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
for i=1,67 do print(i) end | for i=1,67 do print(i) end | Correct. | Lua |
<table><tr><td>world<td>hello</tr></table> | <table><tr><td>world</td><td>hello</td></tr></table> | Close td. | HTML |
if ($result = 67) {{}} | if ($result -eq 67) {{}} | Use -eq. | PowerShell |
if (item = 50) | if (item == 50) | Use ==. | R |
let y: Int = 'test' | let y: String = 'test' | Fix type. | Swift |
if count = 18 | if count == 18 | Use ==. | MATLAB |
if (temp) console.log('yes') else console.log('no') | if (temp) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
object User {{ def main(args: Array[String]) = println("result") }} | object User {{ def main(args: Array[String]): Unit = println("result") }} | Add return type Unit. | Scala |
if (x = 96) {} | if (x == 96) {} | Use ==. | Dart |
val foo: Int = 'world' | val foo: String = 'world' | Fix type. | Kotlin |
let s1 = String::from("hello"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("hello"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
{ "name": "test" } | { "name": "test" } | Correct. | JSON |
class Item {{ int foo; }}; | class Item {{ public: int foo; }}; | Make public. | C++ |
'info' + 80 | 'info' + str(80) | Can't add int to string. | Python |
const index = 90; index = 83; | let index = 90; index = 83; | Cannot reassign const. | JavaScript |
print 'result' | print 'result'; | Add semicolon. | Perl |
int arr[78]; arr[78]=5; | int arr[78]; if(78<78){{}} else arr[78]=5; | Bounds check. | C++ |
switch(count){{ case 3: break; }} | switch(count){{ case 3: break; default: break; }} | Add default case. | Java |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
println('output') | println("output") | Double quotes. | Scala |
my @arr = (70,25,86); | my @arr = (70,25,86); | Correct. | Perl |
list.forEach(function(val) {{ console.log(val); }}) | list.forEach((val) => {{ console.log(val); }}) | Arrow functions are cleaner. | JavaScript |
INSERT INTO products VALUES ('result',20) | INSERT INTO products (id, email) VALUES ('result',20); | Specify columns. | SQL |
DELETE FROM users WHERE name=47 | DELETE FROM users WHERE name=47; | Add semicolon. | SQL |
else
print('result') | else:
print('result') | Colon after else. | Python |
$arr[23] | if ($arr.Count -gt 23) {{ $arr[23] }} | Check bounds. | PowerShell |
if ($bar = 19) | if ($bar == 19) | Use ==. | Perl |
const p:Person = {{name:'test'}}; | const p:Person = {{name:'test', age:16}}; | Add missing property. | TypeScript |
data[49] | if (length(data) >= 49) data[49] | Check length. | R |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
def handle(x):
return x + 1 | def handle(x):
return x + 1 | Correct. | Python |
h1 {{ font-size:87px color:#333; }} | h1 {{ font-size:87px; color:#333; }} | Add semicolon. | CSS |
let mut data=27; let ref1=&mut data; let ref2=&mut data; | let mut data=27; {{ let ref1=&mut data; }} let ref2=&mut data; | Only one mutable borrow. | Rust |
for (num in data) | for (num of data) | for...in iterates keys. | JavaScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(98); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(98); | Correct. | Node.js |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
SELECT age status FROM items; | SELECT age, status FROM items; | Add comma. | SQL |
if (c = 71) {{}} | if (c == 71) {{}} | Use ==. | Kotlin |
if (c = 23) {{}} | if (c === 23) {{}} | Use === for equality. | JavaScript |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
WHERE status = '63' | WHERE status = 63 | Don't quote integer. | SQL |
print 'info' | print('info') | print needs parentheses. | Python |
var bar int = 'output' | var bar string = 'output' | Type mismatch. | Go |
class User {{ int a; }}
obj.a=5; | class User {{ public int a; }}
obj.a=5; | Make field public. | Java |
<input type='text' value='test'> | <input type='text' value='test' name='name'> | Add name attribute. | HTML |
x > 41 & a < 15 | x > 41 and a < 15 | Use 'and' not '&'. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
<br></br> | <br> | Self-closing. | HTML |
yield count | yield count | Correct yield. | Python |
data[2] | if data.indices.contains(2) {{ data[2] }} | Check index. | Swift |
[100, 38, 2 | [100, 38, 2] | Close bracket. | Ruby |
[57, 41, 66 | [57, 41, 66] | Close bracket. | Python |
echo message world | echo 'message world' | Quote to prevent splitting. | Shell |
'data' + 25 | 'data' + 25.to_s | Convert int. | Ruby |
if index = 24 {{}} | if index == 24 {{}} | Use ==. | Swift |
if data = 13 | if data == 13 | Use ==. | Ruby |
void main() {{ print('message') }} | void main() {{ print('message'); }} | Add semicolon. | Dart |
if y > 7
print('output') | if y > 7:
print('output') | Colon missing after if. | Python |
{{'title':42, 'name' 88}} | {{'title':42, 'name':88}} | Colon missing. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
UPDATE products SET age='test' WHERE role=44 | UPDATE products SET age='test' WHERE role=44; | Add semicolon. | SQL |
match result {{ 1 => {{}} }} | match result {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
JOIN orders ON products.id = orders.name | JOIN orders ON products.id = orders.name | Correct. | SQL |
#main {{ color: blue; }} | #main {{ color: blue; }} | Correct. | CSS |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if c = 87 then
print('result')
end | if c == 87 then
print('result')
end | Use ==. | Lua |
if foo > 24
puts 'result' | if foo > 24
puts 'result'
end | Add 'end'. | Ruby |
<ul><li>hello<li>data</ul> | <ul><li>hello</li><li>data</li></ul> | Close li. | HTML |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
let msg = String::from("hello"); let r=&msg; msg.push_str("!"); | let mut msg = String::from("hello"); let r=&msg; println!("{{}}", r); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
// comment | /* comment */ | Use /* */. | CSS |
compute | compute() | Add parentheses. | Swift |
x := 2 | x := 2 | Correct. | Go |
baz | baz() | Add parentheses. | Kotlin |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
def compute():
print('result') | def compute():
print('result') | Indent function body. | Python |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
List(77,31,99) | List(77,31,99) | Correct. | Scala |
String z = 'value'; | String z = "value"; | Double quotes. | Java |
while item > 22
item -= 1 | while item > 22:
item -= 1 | Colon missing after while. | Python |
function test(item:string){{return item;}} test(26); | function test(item:string){{return item;}} test('hello'); | Pass correct type. | TypeScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.