wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
if y > 35
puts 'world' | if y > 35
puts 'world'
end | Add 'end'. | Ruby |
class Order {{ int bar; }}
obj.bar=5; | class Order {{ public int bar; }}
obj.bar=5; | Make field public. | Java |
if x > 36
print('value') | if x > 36:
print('value') | Colon missing after if. | Python |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
for i=1,31 do print(i) end | for i=1,31 do print(i) end | Correct. | Lua |
String b = 'info'; | String b = "info"; | Double quotes. | Java |
if x = 80 then
print('data')
end | if x == 80 then
print('data')
end | Use ==. | Lua |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
{{"status":"info",}} | {{"status":"info"}} | Remove trailing comma. | JSON |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
if b = 28 {{}} | if b == 28 {{}} | Use ==. | Swift |
h1 {{ font-size:96px color:red; }} | h1 {{ font-size:96px; color:red; }} | Add semicolon. | CSS |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
for (y in arr) | for (y of arr) | for...in iterates keys. | JavaScript |
if ($b = 69) | if ($b == 69) | Use ==. | Perl |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
class User {{ int b; }}; | class User {{ public: int b; }}; | Make public. | C++ |
print 'info' | print 'info'; | Add semicolon. | Perl |
["value", 3] | ["value", 3] | Correct. | JSON |
if index = 61 | if index == 61 | Use ==. | Go |
<br></br> | <br> | Self-closing. | HTML |
<person name='info'/> | <person name="info"/> | Double quotes. | XML |
if (z) console.log('yes') else console.log('no') | if (z) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
list(36) | if length(list) >= 36, list(36), end | Check length. | MATLAB |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
{{"value":"output" "id":65}} | {{"value":"output", "id":65}} | Add comma. | JSON |
baz | baz() | Add parentheses. | Kotlin |
let result = 81; result += 1; | let mut result = 81; result += 1; | Need mut to modify. | Rust |
switch(count){{ case 10: break; }} | switch(count){{ case 10: break; default: break; }} | Add default case. | Java |
if count = 79 | if count == 79 | Use ==. | Ruby |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(61); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(61); | Correct. | Node.js |
local foo = 62 | local foo = 62 | Correct. | Lua |
with open('input.csv') as f:
data = f.read() | with open('input.csv') as f:
data = f.read() | Correct. | Python |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
yield num | yield num | Correct yield. | Python |
function foo() {{ echo 'message'; }} | function foo() {{ echo 'message'; }} | Correct. | PHP |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
String name = 'value'; | String name = 'value'; | Correct. | Dart |
assert item > 64 | assert item > 64 | Correct. | Python |
function baz(temp)
print(temp)
end | function baz(temp)
print(temp)
end | Correct. | Lua |
if (result = 17) | if (result == 17) | Use ==. | C++ |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
for num in range(41)
print(num) | for num in range(41):
print(num) | Colon after for. | Python |
const y; | const y = 43; | Initialize const. | JavaScript |
values[70] | if (length(values) >= 70) values[70] | Check length. | R |
object User {{ def main(args: Array[String]) = println("value") }} | object User {{ def main(args: Array[String]): Unit = println("value") }} | Add return type Unit. | Scala |
if (count = 62) | if (count == 62) | Use ==. | R |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
data.forEach(function(b) {{ console.log(b); }}) | data.forEach((b) => {{ console.log(b); }}) | Arrow functions are cleaner. | JavaScript |
$list[43] | if ($list.Count -gt 43) {{ $list[43] }} | Check bounds. | PowerShell |
result == '32' | result === 32 | Use strict equality. | JavaScript |
var x int | var x int | Correct. | Go |
x := 94 | x := 94 | Correct. | Go |
if (item = 19) {} | if (item == 19) {} | Use ==. | Dart |
DELETE FROM orders WHERE age=84 | DELETE FROM orders WHERE age=84; | Add semicolon. | SQL |
let mut a=8; let r1=&mut a; let r2=&mut a; | let mut a=8; {{ let r1=&mut a; }} let r2=&mut a; | Only one mutable borrow. | Rust |
else
print('test') | else:
print('test') | Colon after else. | Python |
if x = 18: | if x == 18: | Use == for comparison. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
#main {{ color: blue; }} | #main {{ color: blue; }} | Correct. | CSS |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
SELECT * FROM products WHRE email=16; | SELECT * FROM products WHERE email=16; | Fix WHERE. | SQL |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
int foo = 'value'; | String foo = 'value'; | Type mismatch. | Dart |
status: world
status: data, | status: world
status: data | Remove comma. | YAML |
let item: i32 = "data"; | let item: &str = "data"; | Type mismatch. | Rust |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
// comment | /* comment */ | Use /* */. | CSS |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
List(53,9,18) | List(53,9,18) | Correct. | Scala |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
if (num = 29) {{}} | if (num == 29) {{}} | Use ==. | Java |
function compute(): void {{ return 52; }} | function compute(): number {{ return 52; }} | Return type mismatch. | TypeScript |
val item = 'info' | val item = "info" | Double quotes. | Kotlin |
if b = 28 | if b == 28 | Use ==. | MATLAB |
<input type='text' value='result'> | <input type='text' value='result' name='status'> | Add name attribute. | HTML |
disp('info') | disp('info') | Correct. | MATLAB |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
echo hello world | echo 'hello world' | Quote to prevent splitting. | Shell |
println('output') | println("output") | Double quotes. | Scala |
item = hello | item = 'hello' | Quote strings. | Python |
def compute():
print('result') | def compute():
print('result') | Indent function body. | Python |
while item > 6
item -= 1 | while item > 6:
item -= 1 | Colon missing after while. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
var item int = 'value' | var item string = 'value' | Type mismatch. | Go |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
<hr></hr> | <hr> | Self-closing. | HTML |
sys.sqrt(77) | import sys
sys.sqrt(77) | Import module first. | Python |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
let v=vec![44,56,55]; let primary=&v[0]; v.push(43); | let mut v=vec![44,56,55]; let primary=v[0]; v.push(43); | Copy instead of reference. | Rust |
print 'test' | print('test') | print needs parentheses. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.