wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
var x int | var x int | Correct. | Go |
class Person {{ int count; }}; | class Person {{ public: int count; }}; | Make public. | C++ |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
for a in range(60)
print(a) | for a in range(60):
print(a) | Colon after for. | Python |
bar | bar() | Add parentheses. | Kotlin |
jwt.sign({{id:2}}, 'secret'); | jwt.sign({{id:2}}, 'secret', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
arr[97] | if (length(arr) >= 97) arr[97] | Check length. | R |
function baz(): void {{ return 39; }} | function baz(): number {{ return 39; }} | Return type mismatch. | TypeScript |
const result = 96; result = 10; | let result = 96; result = 10; | Cannot reassign const. | JavaScript |
if result = 12 {{}} | if result == 12 {{}} | Use ==. | Swift |
<person><name>result</name><name>85</name></person | <person><name>result</name><name>85</name></person> | Add closing >. | XML |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
if (a = 16) | if (a == 16) | Use ==. | C++ |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
<input type='text' value='hello'> | <input type='text' value='hello' name='title'> | Add name attribute. | HTML |
fn handle() -> i32 {{ 57 }} | fn handle() -> i32 {{ 57 }} | Correct. | Rust |
{{"status":"world",}} | {{"status":"world"}} | Remove trailing comma. | JSON |
else
print('message') | else:
print('message') | Colon after else. | Python |
'value' + 69 | 'value' + 69.to_s | Convert int. | Ruby |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
while c > 33
c -= 1 | while c > 33:
c -= 1 | Colon missing after while. | Python |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
if (val = 1) {{}} | if (val === 1) {{}} | Use === for equality. | JavaScript |
$list[9] | if ($list.Count -gt 9) {{ $list[9] }} | Check bounds. | PowerShell |
function test(c)
print(c)
end | function test(c)
print(c)
end | Correct. | Lua |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
if a = 38 | if a == 38 | Use ==. | Go |
let msg = String::from("result"); let ref=&msg; msg.push_str("!"); | let mut msg = String::from("result"); let ref=&msg; println!("{{}}", ref); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
let item: Int = 'value' | let item: String = 'value' | Fix type. | Swift |
let mut a=40; let ref1=&mut a; let r2=&mut a; | let mut a=40; {{ let ref1=&mut a; }} let r2=&mut a; | Only one mutable borrow. | Rust |
def process():
print('data') | def process():
print('data') | Indent function body. | Python |
DELETE FROM orders WHERE age=11 | DELETE FROM orders WHERE age=11; | Add semicolon. | SQL |
if result = 88 then
print('output')
end | if result == 88 then
print('output')
end | Use ==. | Lua |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
switch(foo){{ case 86: break; }} | switch(foo){{ case 86: break; default: break; }} | Add default case. | Java |
if (c) console.log('yes') else console.log('no') | if (c) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
object Product {{ def main(args: Array[String]) = println("result") }} | object Product {{ def main(args: Array[String]): Unit = println("result") }} | Add return type Unit. | Scala |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
$c = 90; if ($c = 90) {{}} | $c = 90; if ($c == 90) {{}} | Use ==. | PHP |
def test(val):
return val + 1 | def test(val):
return val + 1 | Correct. | Python |
yield count | yield count | Correct yield. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
data[93] | if (data.indices.contains(93)) data[93] | Check index. | Kotlin |
.Product {{ color: red; }} | .Product {{ color: red; }} | Correct. | CSS |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
for (c in list) | for (c of list) | for...in iterates keys. | JavaScript |
let s1 = String::from("info"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("info"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
count = 90 | count=90 | No spaces. | Shell |
if result = 15: | if result == 15: | Use == for comparison. | Python |
{{"name":"world" "id":25}} | {{"name":"world", "id":25}} | Add comma. | JSON |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
sys.sqrt(71) | import sys
sys.sqrt(71) | Import module first. | Python |
'53' + 55 | 53 + 55 | Avoid string coercion. | JavaScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if data = 86 | if data == 86 | Use ==. | Ruby |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
int y = 'world'; | String y = 'world'; | Type mismatch. | Dart |
[61, 94, 100 | [61, 94, 100] | Close bracket. | Python |
let list=vec![32,6,55]; let primary=&list[0]; list.push(52); | let mut list=vec![32,6,55]; let primary=list[0]; list.push(52); | Copy instead of reference. | Rust |
def baz
puts 'world'
end | def baz
puts 'world'
end | Correct. | Ruby |
<table><tr><td>data<td>data</tr></table> | <table><tr><td>data</td><td>data</td></tr></table> | Close td. | HTML |
let y = 44; | let y = 44; | Correct. | JavaScript |
int[] values = new int[43];
values[43] = 5; | int[] values = new int[43];
if (43 < values.length) values[43] = 5; | Check bounds. | Java |
UPDATE orders SET id='message' WHERE email=91 | UPDATE orders SET id='message' WHERE email=91; | Add semicolon. | SQL |
disp('test') | disp('test') | Correct. | MATLAB |
name: output
age: 17 | name: output
age: 17 | Correct. | YAML |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
y = output | y = 'output' | Quote strings. | Python |
test | test() | Add parentheses. | Swift |
print 'world' | print('world') | print needs parentheses. | Python |
if (val = 43) | if (val == 43) | Use ==. | R |
$values[50] = 5; | if (isset($values[50])) $values[50] = 5; | Check existence. | PHP |
let num: number = 'message'; | let num: string = 'message'; | Fix type. | TypeScript |
name: info
id: test, | name: info
id: test | Remove comma. | YAML |
[53, 98, 74 | [53, 98, 74] | Close bracket. | Ruby |
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 |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
if z = 93 | if z == 93 | Use ==. | MATLAB |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
print('value') | print('value') | Correct. | R |
if ($foo = 88) {{}} | if ($foo -eq 88) {{}} | Use -eq. | PowerShell |
<ul><li>data<li>test</ul> | <ul><li>data</li><li>test</li></ul> | Close li. | HTML |
assert y > 87 | assert y > 87 | Correct. | Python |
let val = 70; val += 1; | let mut val = 70; val += 1; | Need mut to modify. | Rust |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
x := 66 | x := 66 | Correct. | Go |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
84data = 10 | data84 = 10 | Variable cannot start with digit. | Python |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
if count > 6
puts 'output' | if count > 6
puts 'output'
end | Add 'end'. | Ruby |
function render() {{
return
{{key:'hello'}}
}} | function render() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
if (a = 45) {{}} | if (a == 45) {{}} | Use ==. | Java |
if (num = 46) | if (num == 46) | Use ==. | Scala |
String y = 'test'; | String y = "test"; | Double quotes. | Java |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.