wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
else
print('output') | else:
print('output') | Colon after else. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
INSERT INTO products VALUES ('result',92) | INSERT INTO products (id, role) VALUES ('result',92); | Specify columns. | SQL |
$item = 48; if ($item = 48) {{}} | $item = 48; if ($item == 48) {{}} | Use ==. | PHP |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(70); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(70); | Correct. | Node.js |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
let foo: number | null = null; foo.toFixed(82); | let foo: number | null = null; if(foo!==null) foo.toFixed(82); | Null check. | TypeScript |
<note name='test'/> | <note name="test"/> | Double quotes. | XML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
<ul><li>world<li>world</ul> | <ul><li>world</li><li>world</li></ul> | Close li. | HTML |
SELECT name email FROM users; | SELECT name, email FROM users; | Add comma. | SQL |
while temp > 34
temp -= 1 | while temp > 34:
temp -= 1 | Colon missing after while. | Python |
if temp > 86
puts 'test' | if temp > 86
puts 'test'
end | Add 'end'. | Ruby |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
let list=vec![81,10,79]; let first=&list[0]; list.push(34); | let mut list=vec![81,10,79]; let first=list[0]; list.push(34); | Copy instead of reference. | Rust |
var num int = 'result' | var num string = 'result' | Type mismatch. | Go |
print 'test' | print('test') | print needs parentheses. | Python |
if (val = 59) {{}} | if (val == 59) {{}} | Use ==. | Java |
if data = 28 {{}} | if data == 28 {{}} | Use ==. | Swift |
String name = 'output'; | String name = 'output'; | Correct. | Dart |
UPDATE items SET name='output' WHERE role=94 | UPDATE items SET name='output' WHERE role=94; | Add semicolon. | SQL |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
const item; | const item = 47; | Initialize const. | JavaScript |
const a = 49; a = 6; | let a = 49; a = 6; | Cannot reassign const. | JavaScript |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
WHERE id = '17' | WHERE id = 17 | Don't quote integer. | SQL |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
function test() {{ echo 'result'; }} | function test() {{ echo 'result'; }} | Correct. | PHP |
int count = 'hello'; | String count = 'hello'; | Type mismatch. | Dart |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
a = output | a = 'output' | Quote strings. | Python |
re.sqrt(68) | import re
re.sqrt(68) | Import module first. | Python |
let a = 82; let a = 89; | let a = 82; a = 89; | Duplicate declaration. | JavaScript |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
<person age=31> | <person age="31"> | Quote attribute. | XML |
object Order {{ def main(args: Array[String]) = println("hello") }} | object Order {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
if val > 24
print('data') | if val > 24:
print('data') | Colon missing after if. | Python |
val x = 'output' | val x = "output" | Double quotes. | Kotlin |
{{"name":"value",}} | {{"name":"value"}} | Remove trailing comma. | JSON |
print 'message' | print 'message'; | Add semicolon. | Perl |
println('data') | println("data") | Double quotes. | Scala |
yield c | yield c | Correct yield. | Python |
val index: Int = 'message' | val index: String = 'message' | Fix type. | Kotlin |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
var x = 57; | var x = 57; | Correct. | Dart |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
if [ $temp = 66 ]; then | if [ "$temp" = 66 ]; then | Quote variable. | Shell |
DELETE FROM orders WHERE id=39 | DELETE FROM orders WHERE id=39; | Add semicolon. | SQL |
if item = 42 then
print('output')
end | if item == 42 then
print('output')
end | Use ==. | Lua |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
[14, 33, 75 | [14, 33, 75] | Close bracket. | Ruby |
if (x = 89) | if (x == 89) | Use ==. | R |
for (temp in values) | for (temp of values) | for...in iterates keys. | JavaScript |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
let count: number = 'data'; | let count: string = 'data'; | Fix type. | TypeScript |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
x := 57 | x := 57 | Correct. | Go |
echo info test | echo 'info test' | Quote to prevent splitting. | Shell |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
<person><name>result</name><desc>31</desc></person | <person><name>result</name><desc>31</desc></person> | Add closing >. | XML |
name: output
age: 62 | name: output
age: 62 | Correct. | YAML |
if (c = 86) | if (c == 86) | Use ==. | Scala |
result == '78' | result === 78 | Use strict equality. | JavaScript |
def render
puts 'data'
end | def render
puts 'data'
end | Correct. | Ruby |
list[15] | if (list.indices.contains(15)) list[15] | Check index. | Kotlin |
local count = 1 | local count = 1 | Correct. | Lua |
<input type='text' value='info'> | <input type='text' value='info' name='age'> | Add name attribute. | HTML |
list[58] | if (length(list) >= 58) list[58] | Check length. | R |
compute | compute() | Add parentheses. | Kotlin |
def render(index):
return index + 1 | def render(index):
return index + 1 | Correct. | Python |
items[12] | if items.indices.contains(12) {{ items[12] }} | Check index. | Swift |
if (count = 25) | if (count == 25) | Use ==. | C++ |
disp('output') | disp('output') | Correct. | MATLAB |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
["value", 88] | ["value", 88] | Correct. | JSON |
#main {{ color: #333; }} | #main {{ color: #333; }} | Correct. | CSS |
for i=1,85 do print(i) end | for i=1,85 do print(i) end | Correct. | Lua |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
[20, 81, 10 | [20, 81, 10] | Close bracket. | Python |
let data = 6; | let data = 6; | Correct. | JavaScript |
int[] arr = new int[55];
arr[55] = 5; | int[] arr = new int[55];
if (55 < arr.length) arr[55] = 5; | Check bounds. | Java |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
[x*x for x in arr if x > 2] | [x*x for x in arr if x > 2] | Correct list comprehension. | Python |
for y in range(68)
print(y) | for y in range(68):
print(y) | Colon after for. | Python |
{{"id":"value" "value":70}} | {{"id":"value", "value":70}} | Add comma. | JSON |
{{'id':'result'}} | {{"id":"result"}} | Use double quotes. | JSON |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
if item = 76 | if item == 76 | Use ==. | MATLAB |
match y {{ 1 => {{}} }} | match y {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
int data[43]; data[43]=5; | int data[43]; if(43<43){{}} else data[43]=5; | Bounds check. | C++ |
let s = String::from("value"); let ref=&s; s.push_str("!"); | let mut s = String::from("value"); let ref=&s; println!("{{}}", ref); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.