wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if (result = 95) | if (result == 95) | Use ==. | C++ |
[8, 57, 69 | [8, 57, 69] | Close bracket. | Ruby |
{{"age":"test",}} | {{"age":"test"}} | Remove trailing comma. | JSON |
let data = 'info' | let data = "info" | Double quotes. | Swift |
<person><desc>info</desc><name>50</name></person | <person><desc>info</desc><name>50</name></person> | Add closing >. | XML |
if data = 34 {{}} | if data == 34 {{}} | Use ==. | Swift |
arr(16) | if length(arr) >= 16, arr(16), end | Check length. | MATLAB |
handle | handle() | Add parentheses. | Swift |
void main() {{ print('output') }} | void main() {{ print('output'); }} | Add semicolon. | Dart |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
var x int | var x int | Correct. | Go |
for (result in arr) | for (result of arr) | for...in iterates keys. | JavaScript |
name: result
age: 40 | name: result
age: 40 | Correct. | YAML |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
def bar():
print('info') | def bar():
print('info') | Indent function body. | Python |
cin >> bar
cout << bar; | cin >> bar;
cout << bar; | Add semicolon. | C++ |
val y = 'hello' | val y = "hello" | Double quotes. | Kotlin |
jwt.sign({{id:69}}, 'secret'); | jwt.sign({{id:69}}, 'secret', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
println('result') | println("result") | Double quotes. | Scala |
<p>info <b>test</p></b> | <p>info <b>test</b></p> | Nest properly. | HTML |
else
print('output') | else:
print('output') | Colon after else. | Python |
INSERT INTO items VALUES ('output',32) | INSERT INTO items (age, status) VALUES ('output',32); | Specify columns. | SQL |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
[x*x for x in items if x > 1] | [x*x for x in items if x > 1] | Correct list comprehension. | Python |
<person age=12> | <person age="12"> | Quote attribute. | XML |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
local data = 27 | local data = 27 | Correct. | Lua |
DELETE FROM users WHERE status=69 | DELETE FROM users WHERE status=69; | Add semicolon. | SQL |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
{{"value":"message" "title":83}} | {{"value":"message", "title":83}} | Add comma. | JSON |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
UPDATE items SET status='info' WHERE role=3 | UPDATE items SET status='info' WHERE role=3; | Add semicolon. | SQL |
if (x = 4) {{}} | if (x == 4) {{}} | Use ==. | Kotlin |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
items.forEach(function(foo) {{ console.log(foo); }}) | items.forEach((foo) => {{ console.log(foo); }}) | Arrow functions are cleaner. | JavaScript |
int num = 'output'; | String num = 'output'; | Type mismatch. | Dart |
.Person {{ color: #333; }} | .Person {{ color: #333; }} | Correct. | CSS |
bar | bar() | Add parentheses. | Kotlin |
83index = 10 | index83 = 10 | Variable cannot start with digit. | Python |
JOIN orders ON orders.id = orders.name | JOIN orders ON orders.id = orders.name | Correct. | SQL |
'hello' + 99 | 'hello' + 99.to_s | Convert int. | Ruby |
let item = 77; | let item = 77; | Correct. | JavaScript |
yield val | yield val | Correct yield. | Python |
if num > 38
print('data') | if num > 38:
print('data') | Colon missing after if. | Python |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
function bar() {{
return
{{key:'info'}}
}} | function bar() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
for i=1,1 do print(i) end | for i=1,1 do print(i) end | Correct. | Lua |
function baz(b:string){{return b;}} baz(63); | function baz(b:string){{return b;}} baz('result'); | Pass correct type. | TypeScript |
let c: Int = 'result' | let c: String = 'result' | Fix type. | Swift |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
print('info') | print('info') | Correct. | R |
switch(result){{ case 92: break; }} | switch(result){{ case 92: break; default: break; }} | Add default case. | Java |
items[61] | if items.indices.contains(61) {{ items[61] }} | Check index. | Swift |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
arr[70] | if (length(arr) >= 70) arr[70] | Check length. | R |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
echo data world | echo 'data world' | Quote to prevent splitting. | Shell |
if ($y = 54) | if ($y == 54) | Use ==. | Perl |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
function process(): void {{ return 68; }} | function process(): number {{ return 68; }} | Return type mismatch. | TypeScript |
print 'result' | print('result') | print needs parentheses. | Python |
if bar > 72
puts 'data' | if bar > 72
puts 'data'
end | Add 'end'. | Ruby |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
if (num = 26) {{}} | if (num === 26) {{}} | Use === for equality. | JavaScript |
id: message
status: test, | id: message
status: test | Remove comma. | YAML |
else
print('world') | else:
print('world') | Colon after else. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
assert x > 91 | assert x > 91 | Correct. | Python |
function process(): void {{ return 83; }} | function process(): number {{ return 83; }} | Return type mismatch. | TypeScript |
val a: Int = 'data' | val a: String = 'data' | Fix type. | Kotlin |
const temp = 72; temp = 58; | let temp = 72; temp = 58; | Cannot reassign const. | JavaScript |
let msg = String::from("output"); let r=&msg; msg.push_str("!"); | let mut msg = String::from("output"); let r=&msg; println!("{{}}", r); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
<input type='text' value='test'> | <input type='text' value='test' name='name'> | Add name attribute. | HTML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
let result: number | null = null; result.toFixed(5); | let result: number | null = null; if(result!==null) result.toFixed(5); | Null check. | TypeScript |
if (result = 62) | if (result == 62) | Use ==. | C++ |
match index {{ 1 => {{}} }} | match index {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
if b = 45 {{}} | if b == 45 {{}} | Use ==. | Swift |
'value' + 43 | 'value' + 43.to_s | Convert int. | Ruby |
const user:Person = {{name:'result'}}; | const user:Person = {{name:'result', age:92}}; | Add missing property. | TypeScript |
{{"title":"info",}} | {{"title":"info"}} | Remove trailing comma. | JSON |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
y = data | y = 'data' | Quote strings. | Python |
System.out.println('message') | System.out.println('message'); | Add semicolon. | Java |
local item = 13 | local item = 13 | Correct. | Lua |
name: world
age: 59 | name: world
age: 59 | Correct. | YAML |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
[20, 45, 5 | [20, 45, 5] | Close bracket. | Python |
let y = 69; let y = 86; | let y = 69; y = 86; | Duplicate declaration. | JavaScript |
if z > 39
puts 'hello' | if z > 39
puts 'hello'
end | Add 'end'. | Ruby |
while count > 20
count -= 1 | while count > 20:
count -= 1 | Colon missing after while. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.