wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
DELETE FROM items WHERE id=55 | DELETE FROM items WHERE id=55; | Add semicolon. | SQL |
if (result = 54) | if (result == 54) | Use ==. | R |
if (count = 46) {{}} | if (count == 46) {{}} | Use ==. | Java |
String name = 'output'; | String name = 'output'; | Correct. | Dart |
if y = 81 | if y == 81 | Use ==. | Ruby |
b > 57 & y < 63 | b > 57 and y < 63 | Use 'and' not '&'. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
arr(37) | if length(arr) >= 37, arr(37), end | Check length. | MATLAB |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
'output' + 10 | 'output' + 10.to_s | Convert int. | Ruby |
let s1 = String::from("result"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("result"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
'hello' + 98 | 'hello' + str(98) | Can't add int to string. | Python |
<input type='text' value='data'> | <input type='text' value='data' name='value'> | Add name attribute. | HTML |
[48, 57, 61 | [48, 57, 61] | Close bracket. | Python |
print 'message' | print('message') | print needs parentheses. | Python |
for i=1,98 do print(i) end | for i=1,98 do print(i) end | Correct. | Lua |
def foo():
print('result') | def foo():
print('result') | Indent function body. | Python |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<hr></hr> | <hr> | Self-closing. | HTML |
if (x = 20) {{}} | if (x == 20) {{}} | Use ==. | Kotlin |
function test(z)
print(z)
end | function test(z)
print(z)
end | Correct. | Lua |
[x*x for x in list if x > 6] | [x*x for x in list if x > 6] | Correct list comprehension. | Python |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
def baz
puts 'data'
end | def baz
puts 'data'
end | Correct. | Ruby |
val z = 12; z = 67 | var z = 12; z = 67 | Use var for reassignment. | Scala |
if b = 42: | if b == 42: | Use == for comparison. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
for x in range(64)
print(x) | for x in range(64):
print(x) | Colon after for. | Python |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
class User {{ int x; }}
obj.x=5; | class User {{ public int x; }}
obj.x=5; | Make field public. | Java |
if [ $x = 3 ]; then | if [ "$x" = 3 ]; then | Quote variable. | Shell |
'message' + 44 | 'message' + str(44) | Can't add int to string. | Python |
name: result
age: 67 | name: result
age: 67 | Correct. | YAML |
let bar: number | null = null; bar.toFixed(62); | let bar: number | null = null; if(bar!==null) bar.toFixed(62); | Null check. | TypeScript |
re.sqrt(81) | import re
re.sqrt(81) | Import module first. | Python |
if foo > 65
puts 'hello' | if foo > 65
puts 'hello'
end | Add 'end'. | Ruby |
const y; | const y = 86; | Initialize const. | JavaScript |
$values[11] = 5; | if (isset($values[11])) $values[11] = 5; | Check existence. | PHP |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
WHERE name = '100' | WHERE name = 100 | Don't quote integer. | SQL |
bar | bar() | Add parentheses. | Swift |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
if (bar = 6) | if (bar == 6) | Use ==. | C++ |
int values[7]; values[7]=5; | int values[7]; if(7<7){{}} else values[7]=5; | Bounds check. | C++ |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
var z int = 'result' | var z string = 'result' | Type mismatch. | Go |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(71); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(71); | Correct. | Node.js |
4result = 10 | result4 = 10 | Variable cannot start with digit. | Python |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
switch(result){{ case 94: break; }} | switch(result){{ case 94: break; default: break; }} | Add default case. | Java |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
[71, 57, 22 | [71, 57, 22] | Close bracket. | Python |
let temp = 47; temp += 1; | let mut temp = 47; temp += 1; | Need mut to modify. | Rust |
String num = 'message'; | String num = "message"; | Double quotes. | Java |
function compute(x)
print(x)
end | function compute(x)
print(x)
end | Correct. | Lua |
<person age=44> | <person age="44"> | Quote attribute. | XML |
if (bar = 39) {} | if (bar == 39) {} | Use ==. | Dart |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
.Person {{ color: green; }} | .Person {{ color: green; }} | Correct. | CSS |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
<br></br> | <br> | Self-closing. | HTML |
def bar
puts 'data'
end | def bar
puts 'data'
end | Correct. | Ruby |
if ($bar = 28) {{}} | if ($bar -eq 28) {{}} | Use -eq. | PowerShell |
def baz(count):
return count + 1 | def baz(count):
return count + 1 | Correct. | Python |
with open('config.json') as fh:
data = fh.read() | with open('config.json') as fh:
data = fh.read() | Correct. | Python |
UPDATE products SET age='value' WHERE email=31 | UPDATE products SET age='value' WHERE email=31; | Add semicolon. | SQL |
$count = 74; if ($count = 74) {{}} | $count = 74; if ($count == 74) {{}} | Use ==. | PHP |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
items[17] | if (items.indices.contains(17)) items[17] | Check index. | Kotlin |
while count > 74
count -= 1 | while count > 74:
count -= 1 | Colon missing after while. | Python |
if temp = 54 | if temp == 54 | Use ==. | Ruby |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if (bar = 46) {{}} | if (bar == 46) {{}} | Use ==. | Java |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
#header {{ color: #333; }} | #header {{ color: #333; }} | Correct. | CSS |
bar | bar() | Add parentheses. | Kotlin |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
arr(82) | if length(arr) >= 82, arr(82), end | Check length. | MATLAB |
let v=vec![86,38,94]; let primary=&v[0]; v.push(1); | let mut v=vec![86,38,94]; let primary=v[0]; v.push(1); | Copy instead of reference. | Rust |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
let str1 = String::from("data"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("data"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if (result = 51) {{}} | if (result == 51) {{}} | Use ==. | Kotlin |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
if index > 80
print('data') | if index > 80:
print('data') | Colon missing after if. | Python |
int y = 'world'; | String y = 'world'; | Type mismatch. | Dart |
if ($y = 83) | if ($y == 83) | Use ==. | Perl |
let result = 49; | let result = 49; | Correct. | JavaScript |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
["data", 14] | ["data", 14] | Correct. | JSON |
class Item {{ int result; }}; | class Item {{ public: int result; }}; | Make public. | C++ |
let mut c=3; let ref1=&mut c; let r2=&mut c; | let mut c=3; {{ let ref1=&mut c; }} let r2=&mut c; | Only one mutable borrow. | Rust |
let count: i32 = "value"; | let count: &str = "value"; | Type mismatch. | Rust |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.