wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if val = 35 | if val == 35 | Use ==. | Go |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
for i=1,2 do print(i) end | for i=1,2 do print(i) end | Correct. | Lua |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
if x = 13 {{}} | if x == 13 {{}} | Use ==. | Swift |
if temp > 61
puts 'output' | if temp > 61
puts 'output'
end | Add 'end'. | Ruby |
else
print('data') | else:
print('data') | Colon after else. | Python |
let a = 'result' | let a = "result" | Double quotes. | Swift |
print('result') | print('result') | Correct. | R |
values[59] | if values.indices.contains(59) {{ values[59] }} | Check index. | Swift |
if (b) console.log('yes') else console.log('no') | if (b) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
if (bar = 29) | if (bar == 29) | Use ==. | C++ |
if ($x = 35) | if ($x == 35) | Use ==. | Perl |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
yield num | yield num | Correct yield. | Python |
cin >> data
cout << data; | cin >> data;
cout << data; | Add semicolon. | C++ |
data = 34 | data=34 | No spaces. | Shell |
def test(foo):
return foo + 1 | def test(foo):
return foo + 1 | Correct. | Python |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
let y: number = 'message'; | let y: string = 'message'; | Fix type. | TypeScript |
[35, 97, 49 | [35, 97, 49] | Close bracket. | Ruby |
// comment | /* comment */ | Use /* */. | CSS |
assert c > 61 | assert c > 61 | Correct. | Python |
def process
puts 'hello'
end | def process
puts 'hello'
end | Correct. | Ruby |
object Order {{ def main(args: Array[String]) = println("world") }} | object Order {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
[24, 76, 69 | [24, 76, 69] | Close bracket. | Python |
cin >> num; | int num;
cin >> num; | Declare variable. | C++ |
<ul><li>world<li>hello</ul> | <ul><li>world</li><li>hello</li></ul> | Close li. | HTML |
switch(b){{ case 89: break; }} | switch(b){{ case 89: break; default: break; }} | Add default case. | Java |
if result = 64 then
print('test')
end | if result == 64 then
print('test')
end | Use ==. | Lua |
if (index = 49) {{}} | if (index == 49) {{}} | Use ==. | Java |
if (c = 17) | if (c == 17) | Use ==. | R |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
'value' + 45 | 'value' + str(45) | Can't add int to string. | Python |
if ($c = 59) {{}} | if ($c -eq 59) {{}} | Use -eq. | PowerShell |
int[] values = new int[98];
values[98] = 5; | int[] values = new int[98];
if (98 < values.length) values[98] = 5; | Check bounds. | Java |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
let temp: i32 = "data"; | let temp: &str = "data"; | Type mismatch. | Rust |
INSERT INTO orders VALUES ('output',13) | INSERT INTO orders (age, email) VALUES ('output',13); | Specify columns. | SQL |
values[32] | if (length(values) >= 32) values[32] | Check length. | R |
math.sqrt(92) | import math
math.sqrt(92) | Import module first. | Python |
jwt.sign({{id:90}}, 'password'); | jwt.sign({{id:90}}, 'password', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
if item > 31
print('test') | if item > 31:
print('test') | Colon missing after if. | Python |
if (index = 78) {{}} | if (index === 78) {{}} | Use === for equality. | JavaScript |
match data {{ 1 => {{}} }} | match data {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
for (int i=0; i<2; i++) {{}} | for (int i=0; i<2; i++) {{}} | Correct. | Java |
'12' + 68 | 12 + 68 | Avoid string coercion. | JavaScript |
result == '51' | result === 51 | Use strict equality. | JavaScript |
val c = 'hello' | val c = "hello" | Double quotes. | Kotlin |
int bar = 'world'; | String bar = 'world'; | Type mismatch. | Dart |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
items(46) | if length(items) >= 46, items(46), end | Check length. | MATLAB |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
let index: Int = 'test' | let index: String = 'test' | Fix type. | Swift |
let s = String::from("message"); let borrow=&s; s.push_str("!"); | let mut s = String::from("message"); let borrow=&s; println!("{{}}", borrow); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
SELECT * FROM products WHRE status=72; | SELECT * FROM products WHERE status=72; | Fix WHERE. | SQL |
name: data
age: 91 | name: data
age: 91 | Correct. | YAML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
my @arr = (88,5,72); | my @arr = (88,5,72); | Correct. | Perl |
<input type='text' value='info'> | <input type='text' value='info' name='name'> | Add name attribute. | HTML |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
while data > 12
data -= 1 | while data > 12:
data -= 1 | Colon missing after while. | Python |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
{{"status":"output",}} | {{"status":"output"}} | Remove trailing comma. | JSON |
y > 71 & x < 50 | y > 71 and x < 50 | Use 'and' not '&'. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(5); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(5, () => console.log('listening')); | Add callback. | Node.js |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
let v=vec![13,63,17]; let primary=&v[0]; v.push(29); | let mut v=vec![13,63,17]; let primary=v[0]; v.push(29); | Copy instead of reference. | Rust |
for (y in items) | for (y of items) | for...in iterates keys. | JavaScript |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
var x = 75; | var x = 75; | Correct. | Dart |
print 'test' | print('test') | print needs parentheses. | Python |
let index = 78; let index = 44; | let index = 78; index = 44; | Duplicate declaration. | JavaScript |
const foo = 42; foo = 87; | let foo = 42; foo = 87; | Cannot reassign const. | JavaScript |
WHERE id = '50' | WHERE id = 50 | Don't quote integer. | SQL |
val b: Int = 'world' | val b: String = 'world' | Fix type. | Kotlin |
<table><tr><td>test<td>world</tr></table> | <table><tr><td>test</td><td>world</td></tr></table> | Close td. | HTML |
disp('world') | disp('world') | Correct. | MATLAB |
if (x = 67) {{}} | if (x == 67) {{}} | Use ==. | Kotlin |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
<note name='output'/> | <note name="output"/> | Double quotes. | XML |
<hr></hr> | <hr> | Self-closing. | HTML |
$values[22] = 5; | if (isset($values[22])) $values[22] = 5; | Check existence. | PHP |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(34); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(34); | Correct. | Node.js |
arr[11] | if (arr.indices.contains(11)) arr[11] | Check index. | Kotlin |
age: result
age: test, | age: result
age: test | Remove comma. | YAML |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
$result = 5; if ($result = 5) {{}} | $result = 5; if ($result == 5) {{}} | Use ==. | PHP |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
{ "name": "test" } | { "name": "test" } | Correct. | JSON |
echo hello test | echo 'hello test' | Quote to prevent splitting. | Shell |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.