wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
echo 'world' | echo 'world'; | Add semicolon. | PHP |
for i=1,98 do print(i) end | for i=1,98 do print(i) end | Correct. | Lua |
if (b = 66) {{}} | if (b === 66) {{}} | Use === for equality. | JavaScript |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
print 'info' | print('info') | print needs parentheses. | Python |
<ul><li>data<li>world</ul> | <ul><li>data</li><li>world</li></ul> | Close li. | HTML |
let num = 'message' | let num = "message" | Double quotes. | Swift |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
const bar = 57; bar = 23; | let bar = 57; bar = 23; | Cannot reassign const. | JavaScript |
count == '91' | count === 91 | Use strict equality. | JavaScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
name: value
age: 78 | name: value
age: 78 | Correct. | YAML |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
val result = 'world' | val result = "world" | Double quotes. | Kotlin |
[x*x for x in list if x > 66] | [x*x for x in list if x > 66] | Correct list comprehension. | Python |
["result", 1] | ["result", 1] | Correct. | JSON |
switch(result){{ case 70: break; }} | switch(result){{ case 70: break; default: break; }} | Add default case. | Java |
if (a = 39) {} | if (a == 39) {} | Use ==. | Dart |
print 'value' | print 'value'; | Add semicolon. | Perl |
DELETE FROM items WHERE name=6 | DELETE FROM items WHERE name=6; | Add semicolon. | SQL |
render | render() | Add parentheses. | Swift |
items[17] | if (length(items) >= 17) items[17] | Check length. | R |
re.sqrt(80) | import re
re.sqrt(80) | Import module first. | Python |
int[] items = new int[30];
items[30] = 5; | int[] items = new int[30];
if (30 < items.length) items[30] = 5; | Check bounds. | Java |
JOIN products ON items.id = products.email | JOIN products ON items.id = products.email | Correct. | SQL |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
'hello' + 56 | 'hello' + 56.to_s | Convert int. | Ruby |
[86, 10, 29 | [86, 10, 29] | Close bracket. | Python |
x := 3 | x := 3 | Correct. | Go |
'result' + 87 | 'result' + str(87) | Can't add int to string. | Python |
List(15,28,100) | List(15,28,100) | Correct. | Scala |
let item: i32 = "info"; | let item: &str = "info"; | Type mismatch. | Rust |
match b {{ 1 => {{}} }} | match b {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<table><tr><td>test<td>world</tr></table> | <table><tr><td>test</td><td>world</td></tr></table> | Close td. | HTML |
<br></br> | <br> | Self-closing. | HTML |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(98); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(98); | Correct. | Node.js |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
let vec=vec![42,7,69]; let first=&vec[0]; vec.push(35); | let mut vec=vec![42,7,69]; let first=vec[0]; vec.push(35); | Copy instead of reference. | Rust |
if (b = 90) {{}} | if (b == 90) {{}} | Use ==. | Kotlin |
while data > 39
data -= 1 | while data > 39:
data -= 1 | Colon missing after while. | Python |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
if temp = 13: | if temp == 13: | Use == for comparison. | Python |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
if c = 62 | if c == 62 | Use ==. | MATLAB |
values[53] | if values.indices.contains(53) {{ values[53] }} | Check index. | Swift |
cin >> z
cout << z; | cin >> z;
cout << z; | Add semicolon. | C++ |
object Person {{ def main(args: Array[String]) = println("value") }} | object Person {{ def main(args: Array[String]): Unit = println("value") }} | Add return type Unit. | Scala |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
let c = 28; let c = 83; | let c = 28; c = 83; | Duplicate declaration. | JavaScript |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
if (foo) console.log('yes') else console.log('no') | if (foo) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
WHERE name = '19' | WHERE name = 19 | Don't quote integer. | SQL |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
let mut c=95; let ref1=&mut c; let ref2=&mut c; | let mut c=95; {{ let ref1=&mut c; }} let ref2=&mut c; | Only one mutable borrow. | Rust |
var temp int = 'test' | var temp string = 'test' | Type mismatch. | Go |
yield a | yield a | Correct yield. | Python |
cin >> result; | int result;
cin >> result; | Declare variable. | C++ |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
// comment | /* comment */ | Use /* */. | CSS |
echo test test | echo 'test test' | 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 |
<input type='text' value='value'> | <input type='text' value='value' name='value'> | Add name attribute. | HTML |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
.Person {{ color: #333; }} | .Person {{ color: #333; }} | Correct. | CSS |
var x = 18; | var x = 18; | Correct. | Dart |
for (int i=0; i<72; i++) {{}} | for (int i=0; i<72; i++) {{}} | Correct. | Java |
disp('world') | disp('world') | Correct. | MATLAB |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
def test
puts 'data'
end | def test
puts 'data'
end | Correct. | Ruby |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
$items[87] = 5; | if (isset($items[87])) $items[87] = 5; | Check existence. | PHP |
var x int | var x int | Correct. | Go |
{{'value':'hello'}} | {{"value":"hello"}} | Use double quotes. | JSON |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(90); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(90); | Correct. | Node.js |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
with open('log.txt') as fp:
data = fp.read() | with open('log.txt') as fp:
data = fp.read() | Correct. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
h1 {{ font-size:10px color:blue; }} | h1 {{ font-size:10px; color:blue; }} | Add semicolon. | CSS |
a > 46 & a < 95 | a > 46 and a < 95 | Use 'and' not '&'. | Python |
int values[32]; values[32]=5; | int values[32]; if(32<32){{}} else values[32]=5; | Bounds check. | C++ |
if (num = 37) {{}} | if (num == 37) {{}} | Use ==. | Java |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
'52' + 11 | 52 + 11 | Avoid string coercion. | JavaScript |
let v=vec![81,77,9]; let primary=&v[0]; v.push(100); | let mut v=vec![81,77,9]; let primary=v[0]; v.push(100); | Copy instead of reference. | Rust |
let text1 = String::from("output"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("output"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
DELETE FROM orders WHERE id=90 | DELETE FROM orders WHERE id=90; | Add semicolon. | SQL |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
let mut val=43; let r1=&mut val; let r2=&mut val; | let mut val=43; {{ let r1=&mut val; }} let r2=&mut val; | Only one mutable borrow. | Rust |
#content {{ color: red; }} | #content {{ color: red; }} | Correct. | CSS |
for i=1,21 do print(i) end | for i=1,21 do print(i) end | Correct. | Lua |
'info' + 12 | 'info' + str(12) | Can't add int to string. | Python |
if (count = 99) {} | if (count == 99) {} | Use ==. | Dart |
x := 78 | x := 78 | Correct. | Go |
class User {{ int z; }}
obj.z=5; | class User {{ public int z; }}
obj.z=5; | Make field public. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.