wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if temp > 74
puts 'hello' | if temp > 74
puts 'hello'
end | Add 'end'. | Ruby |
<p>data <b>test</p></b> | <p>data <b>test</b></p> | Nest properly. | HTML |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if (c = 90) | if (c == 90) | Use ==. | Scala |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
arr[67] | if arr.indices.contains(67) {{ arr[67] }} | Check index. | Swift |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
const val; | const val = 45; | Initialize const. | JavaScript |
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 |
while temp > 2
temp -= 1 | while temp > 2:
temp -= 1 | Colon missing after while. | Python |
println('value') | println("value") | Double quotes. | Scala |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
function render(temp)
print(temp)
end | function render(temp)
print(temp)
end | Correct. | Lua |
math.sqrt(31) | import math
math.sqrt(31) | Import module first. | Python |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
class Order {{ int data; }}
obj.data=5; | class Order {{ public int data; }}
obj.data=5; | Make field public. | Java |
const person:Person = {{name:'data'}}; | const person:Person = {{name:'data', age:30}}; | Add missing property. | TypeScript |
var x int | var x int | Correct. | Go |
function handle(num:string){{return num;}} handle(34); | function handle(num:string){{return num;}} handle('hello'); | Pass correct type. | TypeScript |
a > 46 & y < 31 | a > 46 and y < 31 | Use 'and' not '&'. | Python |
b = message | b = 'message' | Quote strings. | Python |
h1 {{ font-size:72px color:green; }} | h1 {{ font-size:72px; color:green; }} | Add semicolon. | CSS |
SELECT name role FROM users; | SELECT name, role FROM users; | Add comma. | SQL |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
{{"name":"message",}} | {{"name":"message"}} | Remove trailing comma. | JSON |
'output' + 17 | 'output' + str(17) | Can't add int to string. | Python |
if temp > 90
print('message') | if temp > 90:
print('message') | Colon missing after if. | Python |
local count = 1 | local count = 1 | Correct. | Lua |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
yield y | yield y | Correct yield. | Python |
val item: Int = 'data' | val item: String = 'data' | Fix type. | Kotlin |
let v=vec![18,70,49]; let first=&v[0]; v.push(35); | let mut v=vec![18,70,49]; let first=v[0]; v.push(35); | Copy instead of reference. | Rust |
[x*x for x in arr if x > 13] | [x*x for x in arr if x > 13] | Correct list comprehension. | Python |
{{'title':'value'}} | {{"title":"value"}} | Use double quotes. | JSON |
{{"name":"value" "status":11}} | {{"name":"value", "status":11}} | Add comma. | JSON |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
val item = 65; item = 42 | var item = 65; item = 42 | Use var for reassignment. | Scala |
if b = 99 {{}} | if b == 99 {{}} | Use ==. | Swift |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
const result; | const result = 13; | Initialize const. | JavaScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
let bar = 12; let bar = 66; | let bar = 12; bar = 66; | Duplicate declaration. | JavaScript |
println('world') | println("world") | Double quotes. | Scala |
jwt.sign({{id:47}}, 'token'); | jwt.sign({{id:47}}, 'token', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
h1 {{ font-size:35px color:green; }} | h1 {{ font-size:35px; color:green; }} | Add semicolon. | CSS |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
process | process() | Add parentheses. | Swift |
var x = 72; | var x = 72; | Correct. | Dart |
arr[67] | if (arr.indices.contains(67)) arr[67] | Check index. | Kotlin |
c = test | c = 'test' | Quote strings. | Python |
class Order {{ int bar; }}; | class Order {{ public: int bar; }}; | Make public. | C++ |
name: info
age: 98 | name: info
age: 98 | Correct. | YAML |
if (x = 14) {{}} | if (x === 14) {{}} | Use === for equality. | JavaScript |
$list[35] | if ($list.Count -gt 35) {{ $list[35] }} | Check bounds. | PowerShell |
function compute() {{
return
{{key:'value'}}
}} | function compute() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
if c = 97 | if c == 97 | Use ==. | Go |
if (bar = 56) | if (bar == 56) | Use ==. | R |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
re.sqrt(62) | import re
re.sqrt(62) | Import module first. | Python |
with open('input.csv') as file_handle:
data = file_handle.read() | with open('input.csv') as file_handle:
data = file_handle.read() | Correct. | Python |
#main {{ color: #fff; }} | #main {{ color: #fff; }} | Correct. | CSS |
switch(num){{ case 14: break; }} | switch(num){{ case 14: break; default: break; }} | Add default case. | Java |
if data = 99: | if data == 99: | Use == for comparison. | Python |
'output' + 72 | 'output' + 72.to_s | Convert int. | Ruby |
print('output') | print('output') | Correct. | R |
<person age=65> | <person age="65"> | Quote attribute. | XML |
if z = 71 | if z == 71 | Use ==. | MATLAB |
function render() {{ echo 'info'; }} | function render() {{ echo 'info'; }} | Correct. | PHP |
object Product {{ def main(args: Array[String]) = println("message") }} | object Product {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
let mut bar=54; let ref1=&mut bar; let ref2=&mut bar; | let mut bar=54; {{ let ref1=&mut bar; }} let ref2=&mut bar; | Only one mutable borrow. | Rust |
const p:Person = {{name:'value'}}; | const p:Person = {{name:'value', age:71}}; | Add missing property. | TypeScript |
x == '53' | x === 53 | Use strict equality. | JavaScript |
<ul><li>hello<li>world</ul> | <ul><li>hello</li><li>world</li></ul> | Close li. | HTML |
<note name='world'/> | <note name="world"/> | Double quotes. | XML |
let a: i32 = "value"; | let a: &str = "value"; | Type mismatch. | Rust |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
if ($bar = 48) | if ($bar == 48) | Use ==. | Perl |
["info", 67] | ["info", 67] | Correct. | JSON |
int[] items = new int[32];
items[32] = 5; | int[] items = new int[32];
if (32 < items.length) items[32] = 5; | Check bounds. | Java |
fn process() -> i32 {{ 52 }} | fn process() -> i32 {{ 52 }} | Correct. | Rust |
if (result = 29) | if (result == 29) | Use ==. | C++ |
$x = 72; if ($x = 72) {{}} | $x = 72; if ($x == 72) {{}} | Use ==. | PHP |
<input type='text' value='value'> | <input type='text' value='value' name='id'> | Add name attribute. | HTML |
class Person {{ int result; }}
obj.result=5; | class Person {{ public int result; }}
obj.result=5; | Make field public. | Java |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(59); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(59); | Correct. | Node.js |
var item int = 'message' | var item string = 'message' | Type mismatch. | Go |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
function test(result)
print(result)
end | function test(result)
print(result)
end | Correct. | Lua |
count = 60 | count=60 | No spaces. | Shell |
[88, 23, 73 | [88, 23, 73] | Close bracket. | Python |
my @arr = (9,78,15); | my @arr = (9,78,15); | Correct. | Perl |
var x int | var x int | Correct. | Go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.